import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class test02
{

	public static void main(String[] args)
	{
		//检查字符串是否符合规则pattern
		String str = "abc123&&edf456&&xyz789";
		String pat = "([a-z]+)([0-9]+)";
		String pat2 = "([0-9]+)([a-z]+)";
		
		//表达式对象
		Pattern pattern = Pattern.compile(pat);
		
		//创建MATCHER对象
		Matcher matcher = pattern.matcher(str);
	
		
		while(matcher.find())
		{
			System.out.println("----------------");
			//group()和group(0)相同，匹配整个规则
			System.out.println(matcher.group());
			
			//group(1)匹配第一个规则组
			System.out.println(matcher.group(1));
			
			//group(2)匹配第一个规则组
			System.out.println(matcher.group(2));
		}
	}

}
